import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/home/Home.vue'),
    meta:{
      index:1
    },
    children:[
      {
        path:'index',
        component: () => import("../components/index/HomeIndex"),
        meta:{
          index:1
        }
      },
      {
        path:'shopcar',
        component: () => import( "../views/ShopCar"),
        meta:{
          index: 2
        }
      },
      {
        path: 'my',
        component: ()=> import("../views/My/My"),
        meta:{
          index:3
        }
      },
      {
        path:'/',
        redirect:'/index'
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/search/Search.vue'),
    meta:{
      index: 2
    }
  },
  {
    path:'/login',
    name:'login',
    component:() => import("../views/login/Login"),
    meta:{
      index: 2
    }
  },
  {
    path:'/itemize',
    name:'itemize',
    component:() => import("../views/commodityList/CommodityClassification"),
    meta:{
      index: 2
    }
  },
  {
    path:'/commodity',
    component:() => import("../views/commodity/Commodity"),
    meta:{
      index: 3
    },
    children:[
      {
        path:'index',
        component:() => import("../components/commodity/CommodityIndex"),
        meta:{
          index: 3
        },
      },
      {
        path:'info',
        component:() => import("../components/commodity/CommodityInfo")
      },
      {
        path: 'comment',
        component: () => import("../components/commodity/CommodityComment")
      },
      {
        path:'/commodity',
        redirect:'index',
      }
    ]
  },
  {
    path:'/willLogin',
    component:() => import("../views/login/WillLogin"),
    meta:{
      index: 4
    },
  },
  {
    path:'/changePwd',
    component:() => import('../views/My/ChangePwd'),
    meta:{
      index:4
    },
  },
  {
    path:'/personal',
    component:()=>import('../views/My/PersonalData'),
    meta:{
      index:4
    },
  },
  {
    path:'/myCollection',
    component:()=>import('../views/My/MyCollection'),
    meta:{
      index:4
    },
  },
  {
    path:'/myAddress',
    component:()=>import('../views/My/MyAddress'),
    meta:{
      index:4
    },
  },
  {
    path:'/addAddress',
    component:()=>import('../components/address/AddAddress'),
    meta:{
      index:5
    },
  }
]

const router = new VueRouter({
  routes
})

export default router
